<tagLib name="strends" />
<include file="Public:header" />
<link href="__TMPL__Static/Css/weebox.css" rel="stylesheet" />
<script type="text/javascript" src="__TMPL__Static/Js/dataList.js"></script>
<script type="text/javascript" src="__TMPL__Static/Js/bgiframe.js"></script>
<script type="text/javascript" src="__TMPL__Static/Js/weebox.js"></script>
<div class="handle-btns">
	<strends:imageBtn value="{%ADOPT}" click="applyHandler(this,'checkList',1)" />
	<strends:imageBtn value="{%REFUSE}" click="applyHandler(this,'checkList',0)" />
	<form action="__APP__">
		<span>{%NAME}</span>
		<select name="mid">
			<option value="0">{%MEDAL_ALL}</option>
			<foreach name="medal_list" item="medal_item">
			<option value="{$medal_item.mid}" <if condition="$mid eq $medal_item['mid']">selected="selected"</if>>{$medal_item.name}</option>
			</foreach>
		</select>
		<small></small>
		<span>{%USER}</span>
		<input class="textinput" type="text" value="{$uname}" name="uname" size="12" />
		<input class="submit_btn" type="submit" value="{%SEARCH}" />
		<input type="hidden" name="{:c('VAR_MODULE')}" value="{$module_name}" />
		<input type="hidden" name="{:c('VAR_ACTION')}" value="check" />
	</form>
</div>
<strends:list 
	id="checkList" 
	style="list" 
	name="item" 
	checkbox="true" 
	action="true" 
	datasource="list" 
	show="user_name:{%USER}|120,name:{%NAME}|120,image|getMedalImg:{%IMAGE}|60,reason:{%REASON}|~left" 
	actionlist="id|getApplyLink=$item" action_width="100" />
<div class="pager">{$page}</div>
<script type="text/javascript">
function applyHandler(obj,id,status)
{
	var ids =  new Array();
	
	if(isNaN(id))
	{
		$("#" + id + " input:checked[name='key']").each(function(){
			ids.push(this.value);
		});
	}
	else
	{
		ids.push(id);
		var parent = $(obj).parent().parent();
		id = parent.parent().parent().attr('id');
	}
	
	ids = ids.join(',');
	if(ids == '')
		return false;
	
	var query = new Object();
	query.id = ids;
	query.status = status;
	query.desc = $("#checkDesc").val();
	
	$.ajax({
		url: APP + '?' + VAR_MODULE + '=' + CURR_MODULE + '&' + VAR_ACTION + '=checkApply',
		type:"POST",
		cache: false,
		data:query,
		dataType:"json",
		success: function(result){
			if(result.isErr == 0)
			{
				$("#" + id + " tbody tr input[name='key']").each(function(){
					if((',' + ids + ',').indexOf(',' + this.value + ',') != -1)
					{
						parent = $(this).parent().parent();
						this.checked = false;
						parent.attr({"disabled":true,"title":ALREADY_REMOVE});
						$("td",parent).attr({"disabled":true}).addClass('disabled');
						$("td *",parent).attr({"disabled":true}).addClass('disabled');
					}
					
					if($("#" + id + " tbody tr:not([disabled])").length == 0)
						location.reload(true);
				});
			}
			else
				$.ajaxError(result.content);
				
			$.weeboxs.close();
		}
	});
}
</script>
<include file="Public:footer" />